package bb.lanxing.activity.sport;

import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.style.UnderlineSpan;
import android.view.View;
import android.widget.TextView;

import bb.lanxing.R;
import bb.lanxing.activity.base.BaseActivity;
import bb.lanxing.net.ApiClientConfigs;
import bb.lanxing.network.MyHttpClient;
import bb.lanxing.util.WebViewBuilder;

public class SettingTTsActivity extends BaseActivity {
    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_setting_tts);
        setupActionBar(true);
        getFragmentManager().beginTransaction().add(R.id.fragment_container, new SettingTTsFragment()).commit();
        initTtsAlert();
    }

    private void initTtsAlert() {
        TextView textView = (TextView) findViewById(R.id.tv_tts_alert);
        if (textView == null) {
            return;
        }
        String string = getString(R.string.sport_setting_tts_alert);
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(string);
        spannableStringBuilder.setSpan(new UnderlineSpan(), string.length() - 4, string.length(), 33);
        textView.setText(spannableStringBuilder);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                WebViewBuilder with = WebViewBuilder.with(view.getContext());
                with.url(ApiClientConfigs.PROTOCOL_HTTP + MyHttpClient.DOMAIN_BASE + "/document/314").start();
            }
        });
    }

    @Override
    public boolean onHomeBack() {
        setResult(-1);
        return super.onHomeBack();
    }

    @Override
    public void onBackPressed() {
        setResult(-1);
        finish();
        super.onBackPressed();
    }
}